<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    @yield('style')
    <link href="{{ asset('plugin/bootstrap-3.3.7-dist/css/bootstrap.css') }}" rel="stylesheet"/>
    <!--<link href="{{ asset('plugin/bootstrap-3.3.7-dist/css/bootstrap-theme.css') }}" rel="stylesheet"/>-->
    <link rel="stylesheet" href="{{ asset('plugin/font-awesome-4.7.0/css/font-awesome.min.css') }}"/>
    <link href="{{ asset('css/style.css') }}" rel="stylesheet"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}"/>
    <title>@yield('title'){{ config('app.name') }}</title>
    <link rel="icon" href="{{ asset('img/fav.ico')}}" type="image/x-icon">
    <link rel="shortcut icon" href="{{ asset('img/fav.ico')}}" type="image/x-icon">
</head>
<body>
    <div id="app">


        <!-- Styles -->
        <nav class="navbar">

            <div class="navbar-func">
                <ul>
                    <li> <a href="javascript:;" id="sidebar-toggler" data-ng-hide="true"><i class="fa fa-bars" aria-hidden="true"></i></a></li>
                    <li> <a href="javascript:;" id="sidebar-refresh" data-ng-hide="true"><i class="fa fa-refresh" aria-hidden="true"></i></a></li>
                </ul>
            </div>

                <div class="navbar-menu">

                    <ul>
                        <li>
                            <!-- Split button -->
                            <div class="btn-group" id="navbar-menu-btn">
                                <button class="btn btn-default btn-sm dropdown-toggle" style="width:120px;font-size:12px" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    {{ Auth::user()->name }} <span class="caret"></span>
                                </button>

                                <ul class="dropdown-menu" id="navbar-menu-dropdown" style="right:0;left:auto;min-width:120px;text-align:left;">
                                    <li><a href="{{ url('user') }}/{{ Auth::user()->id }}/edit">修改密码</a></li>
                                    <li>
                                        <a href="{{ route('logout') }}"
                                           onclick="event.preventDefault();
                                             document.getElementById('logout-form').submit();">
                                            退出
                                        </a>

                                        <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                            {{ csrf_field() }}
                                        </form>
                                    </li>
                                </ul>
                            </div>
                        </li>
                        <!--
                        <li>
                            <a href="{{ route('logout') }}"
                               onclick="event.preventDefault();
                                             document.getElementById('logout-form').submit();">
                                退出
                            </a>

                            <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                {{ csrf_field() }}
                            </form>
                        </li>
                        <li><a href="{{ url('user') }}/{{ Auth::user()->id }}/edit">修改密码</a></li>
                        -->

                        <li id="last-login">
                            <a href="#" style="font-size:12px;color:#999;cursor:default">上次登录 : <strong>{{   (date("Y-m-d H:i:s", Auth::user()->last_login_time)) }}</strong></a>
                        </li>


                    </ul>
                </div>

        </nav>


                <div class="sidebar" id="sidebar" style="">
                    <div class="sidebar-logo" id="navbar-logo" style="">
                        <a class="sidebar-brand" href="{{ url('/') }}">
                            <i class="fa fa-superpowers" aria-hidden="true"></i>
                            {{ config('app.name', 'Laravel') }}
                        </a>
                    </div>
                    @php
                        $admin = 0;
                        $admin = Auth::id();
                    @endphp
                    <div class="sidebar-menu">
                        <h3>功能菜单</h3>
                        <ul>
                            <!--
                            <li>
                                <a href="{{ url('/') }}" class=" @if ($active === 1) active @endif" style="" ><i class="fa fa-bar-chart"></i><span>控制面板</span></a></li>
                            <li> <a href="{{ url('person') }}" class="  @if ($active === 4 || $active === 5 || $active === 6) active @endif" style=""  ><i class="fa fa-id-card" aria-hidden="true"></i><span>人员管理</span></a></li>

                            @if ($admin === 1)
                                <li><a href="{{ url('user') }}" class=" @if ($active === 2 || $active === 3) active @endif" style="" ><i class="fa fa-user" aria-hidden="true"></i><span>管理员</span></a></li>
                            @endif
                            <li><a href="{{ url('home/api') }}" class="@if ($active === 9) active @endif" style="" ><i class="fa fa-cog" aria-hidden="true"></i><span>api管理</span></a></li>

                            <li><a href="{{ url('home/setting') }}" class="@if ($active === 8) active @endif" style="" ><i class="fa fa-cog" aria-hidden="true"></i><span>系统配置</span></a></li>
                            -->
                                <li>
                                    <a href="{{ url('/') }}" class=" @if ($active === 1) active @endif" style="" ><i class="fa fa-tachometer" aria-hidden="true"></i>控制面板</span></a></li>
                                <li class="li-sub">
                                    <a href="javascript:;" class="  @if ($active === 4 || $active === 5 || $active === 6) active @endif" style="">
                                        <i class="fa fa-id-card-o" aria-hidden="true"></i><span>人员管理</span>
                                        <i class="fa  @if ($active !== 4 && $active !== 5 && $active !== 6) fa-arrow-right @else fa-arrow-down  @endif sub-fa" aria-hidden="true"></i>
                                    </a>
                                    <ul class="sub-menu" @if ($active !== 4 && $active !== 5 && $active !== 6) style="display:none" @endif>
                                        <li><a href="{{ url('person/create') }}" class=" @if ($active === 5) active @endif">添加</a></li>
                                        <li><a href="{{ url('person') }}" class=" @if ($active === 4) active @endif">列表</a></li>
                                        <li><a href="{{ url('person/recycleIndex') }}" class=" @if ($active === 6) active @endif">回收站</a></li>
                                    </ul>

                                </li>

                                @if ($admin === 1)
                                    <li class="li-sub">
                                        <a href="javascript:;" class=" @if ($active === 2 || $active === 3) active @endif" style="" >
                                            <i class="fa fa-user-o" aria-hidden="true"></i><span>管理员</span>
                                            <i  class="fa @if ($active !== 2 && $active !== 3) fa-arrow-right @else fa-arrow-down  @endif  sub-fa" aria-hidden="true"></i>
                                        </a>
                                        <ul class="sub-menu" @if ($active !== 2 && $active !== 3) style="display:none" @endif>
                                            <li><a href="{{ url('user/create') }}" class=" @if ($active === 3) active @endif">添加</a></li>

                                            <li><a href="{{ url('user') }}" class=" @if ($active === 2) active @endif">列表</a></li>
                                        </ul>
                                    </li>
                                @endif
                                <li><a href="{{ url('home/setting') }}" class="@if ($active === 8) active @endif" style="" ><i class="fa fa-desktop" aria-hidden="true"></i><span>系统配置</span></a></li>
                                <li><a href="{{ url('home/api') }}" class="@if ($active === 9) active @endif" style="" ><i class="fa fa-usb" aria-hidden="true"></i><span>API管理</span></a></li>
                                <li><a href="{{ url('log/index') }}" class="@if ($active === 10) active @endif" style="" ><i class="fa fa-usb" aria-hidden="true"></i><span>日志</span></a></li>
                        </ul>
                    </div>
                </div>


                    <div class="main-content">
                        <div class="container-fluid" style="position:relative">
                        @if (session('success'))
                            <div class="alert alert-success" id="session_success">
                                {{ session('success') }}
                            </div>
                        @endif
                        @yield('content')
                        </div>
                    </div>
                        @yield('modal')
                <div class="body-shade"></div>
            </div>

    <a href="#0" class="cd-top">Top</a>
    <!--[if IE]>
    <script src=”{{ asset('js/html5shiv.min.js') }}”></script>
    <script src=”{{ asset('js/respond.min.js') }}”></script>
    < ![endif]-->
    <script src="{{ asset('js/jquery.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('js/jQueryRotate.js') }}" type="text/javascript"></script>
    <script src="{{ asset('plugin/bootstrap-3.3.7-dist/js/bootstrap.js') }}"></script>
    <!--
    <script src="{{ asset('plugin/back-to-top/js/modernizr.js') }}"></script>
    <script src="{{ asset('plugin/back-to-top/js/main.js') }}"></script>
    -->
    <script>
        $(function(){
            $('.li-sub>a').click(function(){
                var sub_menu = $(this).next();
                if (sub_menu.css("display") == 'none') {
                    sub_menu.show(20);
                    $(this).find('i.fa-arrow-right').attr('class', 'fa fa-arrow-down sub-fa');
                } else {
                    sub_menu.hide(10);
                    $(this).find('i.fa-arrow-down').attr('class', 'fa fa-arrow-right sub-fa');

                }

            });
            $('.li-sub>a').mouseup(function(){
               $(this).find('i.sub-fa').rotate({ duration:600,angle:0,animateTo:360,easing: $.easing.easeInOutExpo })
            });
        });
    </script>
    @yield('script')

    <script>
        $(function(){
            // 刷新页面
            $('#sidebar-refresh').click(function(){
                $(this).rotate({ duration:100,angle:0,animateTo:360,easing: $.easing.easeInOutExpo })
                window.location.reload();
            });

            // 点击覆盖层关闭左侧导航
            $('.body-shade').click(function(){
//                if ($(this).attr("data-ng-hide") == 'false') {
                    $('#sidebar-toggler').attr("data-ng-hide", 'false');
                    $("#sidebar").hide();
                    $(".navbar-func").animate({'left': "0"}, 300);
                    $(".main-content").animate({'left': "0"}, 300);
                    $('.body-shade').hide();
//                }
            });

            // 页面小于768宽，设置标志data-hg-hide为false
            if ($(window).width() < 768) {
                $('#sidebar-toggler').attr("data-ng-hide", 'false');
            }
            $(window).resize(function(){
                if ($(window).width() < 768) {
                    $('#sidebar-toggler').attr("data-ng-hide", 'false');
                }
            });


            // 设置按钮关闭或开启左侧导航
            $('#sidebar-toggler').click(function(){
                if ($(this).attr("data-ng-hide") == 'true') {
                    $(this).attr("data-ng-hide", 'false');
                    $("#sidebar").hide();
                    $(".navbar-func").animate({'left':"0"}, 300);
                    $(".main-content").animate({'left':"0"}, 300);
                    $('.body-shade').hide();
                    $(this).rotate({ duration:600,angle:0,animateTo:180,easing: $.easing.easeInOutExpo })

                } else {
                    $(this).attr("data-ng-hide", 'true');
                    if ($(window).width() < 768) {
                        $('.body-shade').show();
                    }
                    $("#sidebar").fadeIn(400);
                    $(".navbar-func").animate({'left':"230px"}, 300);
                    $(".main-content").animate({'left':"230px"}, 300);

                    $(this).rotate({ duration:600,angle:180,animateTo:0,easing: $.easing.easeInOutExpo })
                }
            });
        });
    </script>

</body>
</html>
